﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;
using System.Data;

public partial class PubTravelDocInfo : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    public Category model = new Category();
    int count = 0;
    string KeyCode = "xxss";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                try
                {
                    if (string.IsNullOrEmpty(Session["UserLogin"] + ""))
                    {

                        Msg.ShowAndRedirect("未登录或登录已超时!", "TravelDoc.aspx");
                    }
                }
                catch
                {
                    Msg.ShowAndRedirect("未登录或登录已超时!", "TravelDoc.aspx");
                }

            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

    #region 分页绑定
    private void InitData(int PageIndex)
    {
        Customs cmodel = (Customs)Session["UserLogin"];
        DataSet ds = new DataSet();
        ds = bllNews.GetAllListByCodeNo(AspNetPager1.PageSize, PageIndex, KeyCode, "state='1' and isOutlLink='" + cmodel.id + "'", out count);
        AspNetPager1.RecordCount = count;

        this.rptContent.DataSource = ds.Tables[0].DefaultView;
        this.rptContent.DataBind();
    }
    #endregion

    #region 分页控件加载
    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                InitData(e.NewPageIndex);
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    #endregion
    #region 删除
    protected void ibtnDel_OnCommand(object sender, CommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandName);
        int typeid = Convert.ToInt32(e.CommandArgument);
        try
        {
            // 防止网页重复提交

            bllNews.Delete(id);
            string str = " parentId=" + id + " and categoryId=" + typeid;
            Msg.Show("删除成功!");

            InitData(1); //重新绑定
        }
        catch (Exception ex)
        {
          
        }
    }
    #endregion

}
